<?Lassoscript
// Last modified 11/30/09 by Eric Landmann

// FUNCTIONALITY
// Sections form

// CHANGE NOTES
// 4/17/09
// Version 1.0
// 11/30/09
// Worked on admin area

// Debugging
// Var:'svDebug' = 'Y';

// Convert action_params
Include:($svLibsPath)'topic_params.inc';

// If Edit page, get the record
If: (Response_Filepath) >> 'setup_editrecord.lasso';
	// If Process = Y, form was submit, so update the record
	// Otherwise, it is a new edit so get the record
	If: $vProcess != 'Y';
		// Get the record
		Var:'vSQLSearchTopics'='SELECT *
			FROM ' $svTopicsTable ' WHERE Topic_ID = "'($vTID)'" LIMIT 1';
		Inline: $IV_SearchTopics, -Table=$svTopicsTable, -SQL=$vSQLSearchTopics;
			// If Found_Count is wrong, the wrong ID was passed, so dump out 2000 "No Record Found"	
			If: (Found_Count) == 0;
				Var:'vError' = '2000';
				Abort;
			/If;
			Var:'vTopic_ID' = Field:'Topic_ID';
			Var:'vSID' = Field:'Section_ID';
			Var:'vTopic_Title' = Field:'Topic_Title';
			Var:'vPoster' = Field:'Poster';
			Var:'vAllow' = Field:'Allow';
			Var:'vUpdateDate' = Field:'UpdateDate';
		/Inline;
	Else;
		// Update the record
		Inline: $IV_UpdateTopics, 'Severity_ID' = $vSID;
			// If there is an error, dump out error 1012 "Update Failed"
			If: (Error_CurrentError) != 0;
				Var:'vError' = '1012';
			/If;
		/Inline;
	/If;
	
/If;

'<h2>Topic Record</h2>\r';

// Standard Error Table
If: (Var:'vError') != '';
	LI_ShowError3: -ErrNum=$vError, -Option=$vOption;
/If;
?>
<form action="setup_addresponse.lasso" method="post">

	<table border="0" cellpadding="1" cellspacing="1" width="491">
		<tr>
			<td colspan="2"><strong>NOTE: </strong>[$svInputRequired] indicates required information.</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Forum</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
<?Lassoscript
// Get list of Sections
Var:'vSQLSearchSections'='SELECT * FROM ' $svSectionsTable ' ORDER BY Section_Title';
Inline: $IV_SearchSections, -SQL=$vSQLSearchSections;
	'\t<p><select name="SID">\n';
	'\t\t<option value=""'; If: (Var:'vSID') == ''; ' selected'; /If; '>--- Show All---</option>\n';
	Records;
		'\t\t\t<option value="'(Field:'Section_ID') '"'; If: (Field:'Section_ID') == ($vSID); ' selected'; /If; '>'(Field:'Section_Title')'</option>\n';
	/Records;
	'\t\t</select><br></p>\n';
/Inline;
	?> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Topic Title</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="TopicTitle" value="[Var:'vTopic_Title']" size="36" maxlength="64"> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Poster</strong></font>
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<input type="text" name="Poster" value="[Var:'vPoster']" size="24" maxlength="64"> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Allow</strong></font>[$svInputRequired]
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<select name="Allow"> 
					<option value="" [if: (var:'vAllow') == ''] selected[/If]></option>
					<option value="Y" [if: (var:'vAllow') == 'Y'] selected[/if]>Yes</option>
					<option value="N" [if: (var:'vAllow') == 'N'] selected[/if]>No</option>
					<option value="A" [if: (var:'vAllow') == 'A'] selected[/if]>Archive</option>
				</select> 
			</td>
		</tr>
		<tr>
			<td width="130" bgcolor="[Var:'svPostHeaderColor']" valign="top">
				<p align="right">
					<font color="#FFFFFF"><strong>Update Date</strong></font>
				</p>
			</td>
			<td width="520" valign="top" bgcolor="[Var:'svPostContentColor']">
				<p align="left">[Var:'vUpdateDate']</p>
			</td>
		</tr>
			<tr>
				<td colspan="2" bgcolor="[Var:'svTopicHeaderColor']">
					<div align="center">
<?Lassoscript
// If Edit page, add a hidden field to show check if page is submit
// Also add a hidden field with the User_ID
If: (Response_Filepath) >> 'setup_editrecord.lasso';
				'\t\t\t\t<input type="hidden" name="Process" value="Y">\n';
				'\t\t\t\t<input type="hidden" name="TID" value="'($vTID)'">\n';
				'\t\t\t\t<input type="hidden" name="DataType" value="Topic">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Update">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Delete">\n';
Else;
				'\t\t\t\t<input type="hidden" name="DataType" value="Topic">\n';
				'\t\t\t\t<input type="submit" name="Action" value="Add">\n';
/If; ?>				</div>
			</td>
		</tr>
	</table>
</form>
